package com.dtlaya.allutils.dcmThreadUploadInsertDatebase;

//import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.stereotype.Component;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

@Component
public class DicomPerformanceMonitor {

//    private final MeterRegistry meterRegistry;
//    private final AtomicLong totalFilesProcessed = new AtomicLong();
//    private final ConcurrentHashMap<String, AtomicLong> counters = new ConcurrentHashMap<>();
//
//    public DicomPerformanceMonitor(MeterRegistry meterRegistry) {
//        this.meterRegistry = meterRegistry;
//        initMetrics();
//    }
//
//    private void initMetrics() {
//        meterRegistry.gauge("dicom.files.processed.total", totalFilesProcessed);
//        meterRegistry.gauge("dicom.files.storage.time", this::getAverageStorageTime);
//        meterRegistry.gauge("dicom.db.insert.time", this::getAverageInsertTime);
//    }
    
//    public void recordFileProcessed() {
//        totalFilesProcessed.incrementAndGet();
//    }
//
//    public void recordStorageTime(long milliseconds) {
//        getCounter("storage.time").addAndGet(milliseconds);
//        getCounter("storage.count").incrementAndGet();
//    }
//
//    public void recordInsertTime(long milliseconds) {
//        getCounter("insert.time").addAndGet(milliseconds);
//        getCounter("insert.count").incrementAndGet();
//    }
//
//    public double getAverageStorageTime() {
//        long time = getCounter("storage.time").get();
//        long count = getCounter("storage.count").get();
//        return count > 0 ? (double) time / count : 0;
//    }
//
//    public double getAverageInsertTime() {
//        long time = getCounter("insert.time").get();
//        long count = getCounter("insert.count").get();
//        return count > 0 ? (double) time / count : 0;
//    }
    
//    private AtomicLong getCounter(String name) {
//        return counters.computeIfAbsent(name, k -> new AtomicLong());
//    }
}